import os
import concurrent.futures
from custom_logger import CustomLogger
from module1 import func_in_module1
from module2 import func_in_module2

if __name__ == "__main__":
    main_logger = CustomLogger('Main')
    main_logger.set_log_file('main.log')

    main_logger.info('This is an info message from Main')

    num_threads = 4

    log_dir = 'logs'
    if not os.path.exists(log_dir):
        os.mkdir(log_dir)

    with concurrent.futures.ThreadPoolExecutor(max_workers=num_threads) as executor:
        for i in range(num_threads):
            thread_log_file = os.path.join(log_dir, f'thread_{i}.log')
            executor.submit(func_in_module1, i, log_file=thread_log_file)

    main_log_file = os.path.join(log_dir, 'main.log')
    main_logger = CustomLogger('Main')
    main_logger.set_log_file(main_log_file)
    main_logger.info('Main thread - This is a message from the main thread')
